﻿using System.Configuration;

namespace Altairis.Web.Management.Configuration {
    public class ExceptionMailerElement : ConfigurationElement {

        [ConfigurationProperty("enabled", IsRequired = false, DefaultValue = false)]
        public bool Enabled {
            get { return (bool)this["enabled"]; }
            set { this["enabled"] = value; }
        }

        [ConfigurationProperty("excludeSystemUrls", IsRequired = false, DefaultValue = true)]
        public bool ExcludeSystemUrls {
            get { return (bool)this["excludeSystemUrls"]; }
            set { this["excludeSystemUrls"] = value; }
        }

        [ConfigurationProperty("excludeLocalRequests", IsRequired = false, DefaultValue = true)]
        public bool ExcludeLocalRequests {
            get { return (bool)this["excludeLocalRequests"]; }
            set { this["excludeLocalRequests"] = value; }
        }

        [ConfigurationProperty("mailSenderName", IsRequired = false, DefaultValue = "")]
        public string MailSenderName {
            get { return (string)this["mailSenderName"]; }
            set { this["mailSenderName"] = value; }
        }

        [ConfigurationProperty("mailSenderAddress", IsRequired = true, DefaultValue = "sender@example.org")]
        [RegexStringValidator(@"^\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$")]
        public string MailSenderAddress {
            get { return (string)this["mailSenderAddress"]; }
            set { this["mailSenderAddress"] = value; }
        }

        [ConfigurationProperty("mailRecipientAddress", IsRequired = true, DefaultValue = "recipient@example.org")]
        [RegexStringValidator(@"^\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$")]
        public string MailRecipientAddress {
            get { return (string)this["mailRecipientAddress"]; }
            set { this["mailRecipientAddress"] = value; }
        }

        [ConfigurationProperty("maximumSubjectLength", IsRequired = false, DefaultValue = 50)]
        [IntegerValidator(MinValue = 10, MaxValue = 200)]
        public int MaximumSubjectLength {
            get { return (int)this["maximumSubjectLength"]; }
            set { this["maximumSubjectLength"] = value; }
        }


        [ConfigurationProperty("mailPickupFolder", IsRequired = false, DefaultValue = "")]
        public string MailPickupFolder {
            get { return (string)this["mailPickupFolder"]; }
            set { this["mailPickupFolder"] = value; }
        }

    }
}
